<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8"/>
		<title>Machiavel Fantasy - <?php if(isset($_GET['modifier'])){ ?>Modifier un événement <?php } else{ ?> Créer un évènement <?php } ?></title>

        <script src="js/jquery-2.1.3.min.js"></script>
        <link rel="icon" href="images/icone_site/favicon.png">
        <meta http-equiv="X-UA-Compatible" content="IE=edge">
        <meta name="viewport" content="width=device-width, initial-scale=1">

        <!-- Bootstrap -->
        <link href="css/bootstrap.min.css" rel="stylesheet">
        <link href="css/bootstrap-theme.css" rel="stylesheet" type="text/css"/>
        <script type="text/javascript" src="js/bootstrap.min.js"></script>

		<!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
		<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
		<!--[if lt IE 9]>
		  <script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
		  <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
		<![endif]-->

		<link 	href="css/complement.css" rel="stylesheet" type="text/css"/><!--CSS personnaliser-->
		<!--jquery-ui-->
		<link href="css/jquery-ui.min.css" rel="stylesheet">
		<link href="css/jquery-ui.theme.min.css" rel="stylesheet">
		<link href="css/jquery-ui.structure.min.css" rel="stylesheet">
		<script src="js/jquery-ui.min.js"></script>
	</head>
	<body>
		<?php
			include_once("accessoires/header.html");//logo du site
			include_once("accessoires/menu.html");//barre de menu
		?>
		<div class="col-md-2">
			<?php include_once("accessoires/calendrier_aside.php");
				  include_once("accessoires/actualite_mini.php");?>
		</div>
		<div class="col-md-8 contenu">
			<h3 class="underline"><?php if(isset($_GET['modifier'])){ ?>Modifier un événement <?php } else { ?> Créer un évènement <?php } ?></h3>
			<form action="edit_actualite.php<?php if(isset($_GET['modifier'])) echo "?modifier=".$id_event;?>" method="POST" class="form-horizontal">
			  <div class="form-group">
				<label for="inputEmail3" class="col-sm-2 control-label">Sujet</label>
				<div class="col-sm-10">
					<input type="text" class="form-control" id="title_event" name="title_event" value="<?php if(isset($title_event)){ echo $title_event;} ?>">
					
					<!------------------Message d'erreur si on n'a pas mis de titre ------------------------>
					<?php if (isset($error_data[1])){ ?>
						<div class="alert alert-danger alert-dismissible" role="alert" >
						  <button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button>
						  <strong><span class="glyphicon glyphicon-alert" aria-hidden="true"></span>&nbsp;</strong><?php echo $error_data[1]; ?>
						</div>
					<?php } ?>
				</div>
			  </div>
			  <div class="form-group">
				<label for="inputdate" class="col-sm-2 control-label">Partie de </label>
				<div class="col-sm-10">
					<select class="form-control time" style="width:27.3%;" name="title_jeu">
					  <?php $i=0; while (isset($title[$i])) { ?>
					  <option <?php if(isset($title_jeu) && $title[$i]==$title_jeu){echo 'selected="selected"';} ?> ><?php echo $title[$i];$i++; ?></option>
					  <?php } ?>
					</select>
					<div style="width:3%;text-align:center; display:inline-block;">le</div>
					<input readonly="readonly" type="text" class="form-control" style="width:15%; display:inline-block; text-align:center;" id="inputdate" name="date" value="<?php if(isset($date)){ echo $date;} ?>">								
					<div style="width:3%;text-align:center; display:inline-block;">à</div>
					<select class="form-control time" name="hour_begin">
					  <?php for ($i=0; $i<=23;$i++) { ?>
					  <option <?php if((isset($hour_begin)) && $i==$hour_begin){echo 'selected="selected"';} ?> ><?php echo sprintf("%'.02d", $i); ?></option>
					  <?php } ?>
					</select>
					<b style="width:1%;text-align:center; display:inline-block;">h</b>
					<select class="form-control time" name="minute_begin">
					  <?php for ($i=0; $i<60;$i+=5) { ?>
					  <option <?php if((isset($minute_begin)) && $i==$minute_begin) {echo 'selected="selected"';} ?> ><?php echo sprintf("%'.02d", $i); ?></option>
					  <?php } ?>
					</select>
				<!----------Message d'alerte si on n'a pas renseigner de date------------------------->
				<?php if (isset($error_data[3])){ ?>
					<div class="alert alert-danger alert-dismissible" role="alert">
					  <button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button>
					  <strong><span class="glyphicon glyphicon-alert" aria-hidden="true"></span>&nbsp;</strong><?php echo $error_data[3]; ?>
					</div>
				<?php } ?>
				</div>
			  </div>
			  <div class="form-group">
				<label for="inputtext" class="col-sm-2 control-label">Corps du message</label>
				<div class="col-sm-10">
				  <textarea class="form-control" rows="20" style="resize:none;" name="text_event"><?php if (isset($text_event))echo $text_event; ?></textarea>
				
					<!----------Message d'alerte si on n'a pas mis de texte------------------------->
					<?php if (isset($error_data[2])){ ?>
						<div class="alert alert-danger alert-dismissible" role="alert">
						  <button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button>
						  <strong><span class="glyphicon glyphicon-alert" aria-hidden="true"></span>&nbsp;</strong><?php echo $error_data[2]; ?>
						</div>
					<?php } ?>
				</div>
			  </div>
			  <div class="form-group">
				<div class="col-sm-offset-2 col-sm-10">							
					<?php if(isset ($_GET['modifier']))
					{ ?>
						<button type="submit" class="btn btn-default" name="update"> Modifier </button><?php
					}
					else	{ ?>
						<button type="submit" class="btn btn-default" name="create"> Créer </button>
					<?php } ?>
					<button type="reset" class="btn btn-default" > Réinialiser </button>
				</div>
			  </div>
			</form>
		</div>
		<?php 
			include_once("accessoires/chat.php");
			include_once("accessoires/footer.html");
		?>
		<script>
			var d = new Date();
			var month = d.getMonth()+1;
			var day = d.getDate();
			var output = d.getFullYear() + '/' +
					(month<10 ? '0' : '') + month + '/' +
					(day<10 ? '0' : '') + day;

			$(function() {
				$( "#inputdate" ).datepicker({minDate:new Date()});
			});
		</script>
	</body>
</html>	